import sqlite3

conn = sqlite3.connect('./example.db')    #创建一个connection对象，代表数据库。即本句的意思为数据将存在example.db文件中。

c = conn.cursor()                       #创建一个cursor游标对象，然后调用它的execute()方法来执行SQL语句。  

# Create table
c.execute('''CREATE TABLE stocks
        (date text,trans text,symbol text,qty real,price real)''')

# Insert a row of data
c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")

# Save (commit) the changes
conn.commit()

# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
